package com.material.vtool.service.impl;

import com.material.vtool.entity.BMaterialTypeInfoEntity;
import com.material.vtool.entity.combinedEntity.CombinedArticleTypeIntoEntity;
import com.material.vtool.mapper.MaterialTypeInfoMapper;
import com.material.vtool.service.MaterialTypeInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Optional;

@Service
public class MaterialTypeInfoServiceImpl implements MaterialTypeInfoService {
    @Autowired
    private MaterialTypeInfoMapper materialTypeInfoMapper;

    @Override
    public CombinedArticleTypeIntoEntity getMaterialTypeById(Integer materialTypeId) {
        return materialTypeInfoMapper.getMaterialTypeById(materialTypeId);
    }

    @Override
    public Integer getMaterialParentTypeId(Integer materialTypeId) {
        return Optional.ofNullable(materialTypeInfoMapper.getMaterialParentTypeId(materialTypeId)).orElse(Integer.valueOf(0));
    }
}
